# encoding: utf-8

class Dataobject < ActiveRecord::Base
  belongs_to  :project,
              :touch  =>  true

  belongs_to  :bug,
              :touch  =>  true

  # Validations
  validates :bug_id,
            :numericality =>  { :only_integer => true,
                                :greater_than => 0,
                                :allow_nil => true,
                                :allow_blank => true}

  validates :name,
            :presence =>  true,
            :length   =>  { :within => 5..255 }, :unless => "self.name.empty?"

  validates :description,
            :presence =>  true,
            :length   =>  { :within => 1..500, :unless => "self.description.empty?",
                            :allow_nil => true  }

  validates :path,
            :presence =>  true,
            :length   =>  { :within => 2..255 }

  validates :project_id,
            :presence     =>  true,
            :numericality =>  { :only_integer => true,
                                :greater_than => 0,
                                :allow_nil => true,
                                :allow_blank => true}

end


# == Schema Information
#
# Table name: dataobjects
#
#  id          :integer         not null, primary key
#  bug_id      :integer
#  name        :string(255)
#  description :text
#  path        :string(255)
#  project_id  :integer
#  created_at  :datetime
#  updated_at  :datetime
#

